package com.example.demo.controller;


import com.example.demo.model.UserInfo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

@RequestMapping("/user/t1")
@RestController
public class UserController {
    @RequestMapping("/hello/t2")
    public String hello(){
        return "hello";
    }
    @RequestMapping("/r1")
    public String r1(String name){
        return "接收到参数 name:"+name;
    }
    @RequestMapping("/r2")
    public String r2(Integer age){
        return "接收到参数 age:"+age;
    }
    @RequestMapping("/r3")
    public String r3(UserInfo userInfo){
        return userInfo.toString();
    }
    @RequestMapping("/r11")
    public String r11(MultipartFile file) throws IOException {
        String filename = file.getOriginalFilename();
        file.transferTo(new File("D:/java109/aaa/"+filename));
        return "获取上传文件"+filename;
    }
}
